package br.com.character.flex.chorm.core.sql
{
    import br.com.character.flex.chorm.core.annotation.IAnnotation;

    [Bindable]
    public class Field implements IField 
    {
         
        private var _name:String;
        private var _alias:String;
        private var _value:IValue;
        private var _annotations:Vector.<IAnnotation>;
        
        public function Field(n:String=null, a:String=null, v:IValue=null)
        {
            _name = n;
            _alias = a;
            _value = v;
        }
        
        public function get value():IValue
        {
            return _value;
        }

        public function set value(value:IValue):void
        {
            _value = value;
        }

        public function get alias():String
        {
            return _alias;
        }

        public function set alias(value:String):void
        {
            _alias = value;
        }

        public function get name():String
        {
            return _name;
        }

        public function set name(value:String):void
        {
            _name = value;
        }

        public function get annotations():Vector.<IAnnotation>
        {
            return _annotations;
        }

        public function set annotations(value:Vector.<IAnnotation>):void
        {
            _annotations = value;
        }
        
        public function toSQL():String {
            var result:String = null;
            result += appendName();
            result += appendAlias();
            return result;
        }
        
        public function appendAlias():String {
            var result:String = null;
            if(result!=null){
                result = " " + result ;
            }
            return result;
        }
        
        public function appendName():String {
            var result:String = null;
            if(result!=null){
                result = " " + result ;
            }
            return result;
        }
    }
}